﻿@using GoodMan.Infrastructure.Entities.Entity;
@using GoodMan.Infrastructure.Entities.Contract;
@using GoodMan.Tool.Framework;
@{
    ViewBag.Title = "duty";
    Layout = "/Areas/WorkSpace/Views/Shared/_CollegeAdminTemplete.cshtml";
}
<div id="content-header">
    <h1>
        楼栋排班</h1>
</div>
<div id="breadcrumb">
    <a href="index.html" title="Go to Home" class="tip-bottom"><i class="icon-home"></i>
        首页</a> <a href="#" class="tip-bottom">楼栋管理</a> <a href="#" class="current">每日排班</a>
</div>
<div class="container-fluid">
    <div class="row-fluid">
        <div class="span12">
            <div class="widget-box">
                <div class="widget-title">
                    <h5>
                        楼栋排班详情</h5>
                </div>
                <div class="widget-content nopadding">
                    <form id="queryform" action="/workspace/CollegeAdmin/duty" method="post" class="form-horizontal">
                    <div class="row-fluid">
                        <div class="span12" style="height: 40px;">
                            <div class="span2 text-right" style="padding-top: 5px;">
                                排班查询：</div>
                            <div class="span8">
                                <div id="querystart" class="input-append span5">
                                    <input id="txtquerystart" data-format="yyyy-MM-dd" type="text" name="querystart"
                                        class="{required:true,dateISO:true}" />
                                    <span class="add-on"><i class="icon-calendar" data-time-icon="icon-time" data-date-icon="icon-calendar">
                                    </i></span>
                                </div>
                                <div id="queryend" class="input-append span5">
                                    <input id="txtqueryend" data-format="yyyy-MM-dd" type="text" name="queryend" class="{required:true,dateISO:true}" />
                                    <span class="add-on"><i class="icon-calendar" data-time-icon="icon-time" data-date-icon="icon-calendar">
                                    </i></span>
                                </div>
                                <button type="submit" class="btn btn-primary" style="margin-left: 40px;">
                                    <i class="icon-search icon-white"></i>查询</button>
                            </div>
                            <div class="span2">
                                <a href="/workspace/collegeadmin/newdutyset" class="btn btn-success">新增排班</a>
                            </div>
                        </div>
                    </div>
                    </form>
                    <table border="0" cellpadding="0" cellspacing="0">
                        <tr>
                            <td colspan="3">
                                <table class="table table-bordered table-striped">
                                    <thead>
                                        <tr>
                                            <th width="10%">
                                                排班日期
                                            </th>
                                            <th width="10%">
                                                排班操作员
                                            </th>
                                            <th width="10%">
                                                设置时间
                                            </th>
                                            <th>
                                                排班详情
                                            </th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        @{
                                            ItemListBox<Duty> data = ViewBag.Duty;
                                            if (data != null && data.Data != null && data.Data.Any())
                                            {
                                                foreach (var item in data.Data)
                                                {
                                            <tr>
                                                <td style="vertical-align: middle">
                                                    @item.Date
                                                </td>
                                                <td style="vertical-align: middle">
                                                    @item.Creator
                                                </td>
                                                <td style="vertical-align: middle">
                                                    @item.RecordDate.ToString("yyyy-MM-dd HH:mm")
                                                </td>
                                                <td style="vertical-align: middle">
                                                    @{
                                                    DutySet duty = item.Content.ToObject<DutySet>();
                                                    if (duty != null && duty.duty != null && duty.duty.Any())
                                                    {
                                                        foreach (var ditem in duty.duty)
                                                        {
                                                            var dormitory = new Dormitory().Find(ditem.Dormitory.ToString());
                                                            if(dormitory != null)
                                                            {
                                                        <div>
                                                            楼栋&nbsp @dormitory.Name&nbsp;&nbsp：</div>
                                                        <div>
                                                        早班：
                                                        @if(ditem.userList.first != null) {
                                                            @ditem.userList.first.Realname
                                                        }
                                                        else{
                                                            @:未设定
                                                        }
                                                        中班：
                                                        @if(ditem.userList.middle != null){
                                                            @ditem.userList.middle.Realname
                                                        }
                                                        else{
                                                            @:未设定
                                                        }
                                                        晚班：
                                                        @if(ditem.userList.last != null){
                                                            @ditem.userList.last.Realname
                                                        }
                                                        else{
                                                            @:未设定
                                                        }
                                                        </div>
                                                        <hr />
                                                        }
                                                        }
                                                    }
                                                    }
                                                </td>
                                            </tr>
                                                }
                                            }
                                        }
                                    </tbody>
                                </table>
                            </td>
                        </tr>
                    </table>
                </div>
                @Html.Raw(data.PageItemSegment)
            </div>
        </div>
    </div>
</div>
@section tail{
    <script type="text/javascript" src="/Scripts/jquery.validate.js"></script>
    <script type="text/javascript" src="/Scripts/jquery.metadata.js"></script>
    <script type="text/javascript" src="/Scripts/bootstrap-datetimepicker.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $('#likDormitory').addClass('open active');
            $('#querystart').datetimepicker({
                pickTime: false
            });
            $('#queryend').datetimepicker({
                pickTime: false
            });
            $('#queryform').validate({
                errorClass: "help-inline",
                errorElement: "span",
                highlight: function (element, errorClass, validClass) {
                    $(element).parents('.control-group').addClass('error');
                },
                unhighlight: function (element, errorClass, validClass) {
                    $(element).parents('.control-group').removeClass('error');
                }
            });
        });
    </script>
}
